
#ifndef BYTE_UTIL_H
#define BYTE_UTIL_H

#include "ISO8583_inc.h"

namespace suxw
{
    class ByteUtil
    {
    public:
        //convert ascii string to bcd data buffer
        //nLen - length of ascii string
        static bool convertAsc2Bcd(unsigned char* pcBcd, const char *pcAsc, int nLen, AlignType alignType, char cPadChar);

        //convert bcd data buffer to ascii string
        //nLen - count of ascii characters
        static bool convertBcd2Asc(const unsigned char* pcBcd, char *pcAsc, int nLen, AlignType alignType);

        //convert 2 ascii char to bcd char
        //pcAsc is address of charater buffer, the char is digit or belong to ['a', 'f']
        static unsigned char asc2Bcd(const char *pcAsc);

    private:
        //judge is valid char
        static bool isValidChar(char c);
        
    public:
        static const int MAX_SIZE = 4 * 1024;
        static unsigned char m_buf[MAX_SIZE];
    };
}

#endif //BYTE_UTIL_H
